package com.yinhd.study.designPatterns.chainOfResponsibility.loggers;

/**
 * @program: study
 * @description:
 * @Author: chengl
 * @create: 2022-01-25 16:31
 **/
public class ChainPatternDemo {
    public static AbstractLogger getAbstractLogger(){
        ConsoleLogger consoleLogger = new ConsoleLogger(AbstractLogger.INFO);
        FileLogger fileLogger = new FileLogger(AbstractLogger.DEBUG);
        ErrorLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        errorLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(consoleLogger);
        return errorLogger;
    }

    public static void main(String[] args) {
        AbstractLogger abstractLogger = ChainPatternDemo.getAbstractLogger();
        abstractLogger.printlnMessage(AbstractLogger.ERROR,"错误日志");
    }
}
